from starlette.endpoints import HTTPEndpoint
from starlette.responses import JSONResponse
from model.ModBureauMonRep import BureauMonRep, bureauMonRepSchema
from database import Session, engine
import datetime
from sqlalchemy import Date, DateTime


def get_monthrep_info(session, monthnum: Date, area_flag: str):
    # 根据月份查询供电局指标排名月报
    monthrep_info = session.query(BureauMonRep).filter(BureauMonRep.monthnum == monthnum).filter(
        BureauMonRep.area_flag == area_flag).order_by(
        BureauMonRep.bureauid.asc()).all()
    return JSONResponse(bureauMonRepSchema.dump(monthrep_info, many=True).data)
